package com.muse.interceptor;

import com.muse.entity.UserInfo;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CurrentContext {

    private CurrentContext() {

    }

    private static final ThreadLocal<UserInfo> LOCAL = new ThreadLocal<UserInfo>();

    public static void set(UserInfo user) {
        LOCAL.set(user);
        ;
    }

    public static UserInfo get() {
        return LOCAL.get();
    }

    public static Integer getUserId() {
        log.info("currentContext info: {}", get());
        return get().getId();
    }

    public static void remove() {
        LOCAL.remove();
    }
}
